<include file="public@header"/>
<style type="text/css">
    .thumb{max-height: 120px;}
</style>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="javascript:;">活动列表</a></li>
        <li><a href="{:url('AdminActivity/add')}">添加活动</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="post" action="{:url('AdminActivity/index')}">
        <!--分类:-->
        <!--<select class="form-control" name="category" style="width: 140px;">-->
            <!--<option value='0'>全部</option>-->

        <!--</select> &nbsp;&nbsp;-->
        发布时间:
        <input type="text" class="form-control js-bootstrap-datetime" name="start_time"
               value="{$start_time|default=''}"
               style="width: 140px;" autocomplete="off">-
        <input type="text" class="form-control js-bootstrap-datetime" name="end_time"
               value="{$end_time|default=''}"
               style="width: 140px;" autocomplete="off"> &nbsp; &nbsp;
        关键字:
        <input type="text" class="form-control" name="keyword" style="width: 200px;"
               value="{$keyword|default=''}" placeholder="请输入关键字...">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('AdminActivity/index')}">清空</a>
    </form>

    <form class="js-ajax-form" action="" method="post">
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th>ID</th>
                <th>标题</th>
                <th>公众号活动页</th>
                <th>发起人</th>
                <th>报名上限人数</th>
                <th>参与人次</th>
                <th>发布时间</th>
                <th>活动日期</th>
                <th>活动时间</th>
                <th>操作</th>
            </tr>
            </thead>

            <foreach name="data" item="vo">
                <tr>
                    <td>{$vo.id}</td>
                    <td>
                            <if condition="!empty($vo.show)">
                                <a href="{:cmf_url('portal/Activity/act_show',array('id'=>$vo['id']))}" target="_blank">{$vo.title}</a>
                            <else/>
                                <a href="{:cmf_url('portal/Activity/act_adv',array('id'=>$vo['id']))}" target="_blank"> {$vo.title}</a>
                            </if>
                       </td>
                    <td ><img class="thumb" src="{$vo.qrcode|get_qrcode}"/></td>
                    <td>{$vo.user.user_nickname}</td>
                    <td>{$vo.max_people==0?'无限制':$vo.max_people}</td>
                    <td>{$vo.log|count}</td>
                    <td>{$vo.ctime|date="Y-m-d H:i"}</td>
                    <td>[<b>{$vo.start_time|date="Y-m-d"}</b>]</td>
                    <td>[<b>{$vo.start_time|date="H:i:s"}</b>]-[<b>{$vo.end_time|date="H:i:s"}</b>]</td>
                    <td>
                        <a class="btn btn-xs btn-primary" href="{:url('AdminActivity/add',['id'=>$vo.id])}">编辑</a>
                        <a class="btn btn-xs btn-info" href="{:url('AdminActivity/add',['id'=>$vo.id,'copy'=>true])}">复制</a>
                        <a class="btn btn-xs btn-warning btn-fixqr" data-id="{$vo.id}" href="">更新二维码</a>
                        <a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('AdminActivity/activity_del',['id'=>$vo.id])}">删除</a>
                    </td>

                </tr>
            </foreach>

        </table>
        <ul class="pagination">{$page|default=''}</ul>
    </form>


</div>
<script src="__STATIC__/js/admin.js"></script>
<script src="__TMPL__/public/assets/plugins/layer/layer.js"></script>
<script>

(function($){
    "use strict";
    function ajax_fix_qr(_id,_that){
        $.ajax({
            url:'{:url("AdminActivity/fix_qr")}',
            method:'POST',
            data:{id:_id},
            success:function(rsp){
                layer.msg(rsp.errmsg);
                if(rsp.error) return;
                _that.closest('tr').find('.thumb').prop('src',rsp.data);
               
            }
        })
    }
    function bind_events(){
        $('.btn-fixqr').off("click").on("click",function(e){
            e.preventDefault();
            var _that =$(this);
            var _id = _that.data('id');
            ajax_fix_qr(_id,_that);

        })
    }   
    $(function(){
        bind_events();
    })
})(jQuery)

</script>
</body>
</html>